package com.woniuxy.service.aspect;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;

/**
 * @Author: 马宇航
 * @Todo: 切面类，内部就是定义具体的前置后置方法的实现的
 * @DateTime: 22/03/28/0028 下午 2:14
 * @Component: 成都蜗牛学苑
 **/
public class MyAspect implements MethodInterceptor {
    public void log(){
        System.out.println("日志记录开始……");
    }
    public void commitTransation(){
        System.out.println("提交事务！");
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        log();
        Object proceed = invocation.proceed();
        commitTransation();
        return proceed;
    }
}
